Mastering Exploratory Analysis with pandas by Harish Garg

Mastering Exploratory Analysis with pandas by Harish Garg

Author:Harish Garg
Language: eng
Format: epub
Tags: COM051360 - COMPUTERS / Programming Languages / Python, COM018000 - COMPUTERS / Data Processing, COM062000 - COMPUTERS / Data Modeling and Design
Publisher: Packt Publishing
Published: 2018-09-29T11:23:08+00:00


Changing an int datatype column to a float

To do this, we first check the datatypes of columns from our real dataset:

data.dtypes

The following is the output:

We then use the astype method to change the datatype. We pass float to the astype method and call this method on the column, the datatype of which we want to change.

We assign the change back to the original column as follows:

data['Zhvi'] = data.Zhvi.astype(float) data.dtypes

In the following screenshot, we can see that the change has been made—the datatype of our column has been changed from int64 to float64:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.